<!--页面组件-->
<template>
  <div>
    <div class="tempxyz addtask">
      <CCard class="cdHead">
        <CCardBody class="card-body" style="margin-top: -70px">
          <div class="cardstyle">
            <!-- 第一行 -->
            <CRow class="rowstyle">
              <!-- <CCol sm="6" class="myColtemp" style>
                <label class="label">任务类型</label>
                <CSelect
                  @change="pushTaskTypeChange($event)"
                  :value.sync="pushTaskType"
                  horizontal
                  :options="taskTypeList"
                  class="input"
                />
              </CCol> -->
              <CCol sm="6" class="myColtemp" style>
                <label class="label">任务名称</label>
                <Input
                  v-model="addData.taskName"
                  placeholder="请输入任务名称"
                  horizontal
                  class="input"
                />
              </CCol>
              <CCol sm="6" class="myColtemp" style>
                <label class="label">扫描间隔</label>
                <Select
                  horizontal
                  v-model="addData.crontabExpress"
                  placeholder="请选择"
                  class="input"
                  @on-change="selectcronType"
                  label-in-value>
                  <Option
                    v-for="item in crontabExpressTypeList"
                    :value="item.value"
                    :key="item.label"
                    >{{ item.label }}</Option>
                </Select>
              </CCol>
            </CRow>

            <!-- <CRow>
              <CCol sm="6" class="myColtemp" style>
                <label class="label">文件类型</label>
                <CSelect
                  horizontal
                  :options="fileTypeList"
                  :value.sync="curFileType"
                  placeholder="请选择文件类型"
                  @change="selectFileType($event)"
                  class="input"
                />
              </CCol>
            </CRow> -->
            <!-- 第二行 -->
            <CRow class="rowstyle">
              <CCol sm="6" class="myColScan" style>
                <label class="label">提取目录</label>
                <Input
                  v-model="addDataTaskParam.processPath"
                  placeholder="请输入提取目录"
                  horizontal
                  class="input"
                />
                <CButton
                  color="info"
                  size="sm"
                  @click="selectPushTaskScanDir('scanDir')"
                  class="btnSelectScanDir"
                  >...</CButton>
              </CCol> 

              <CCol sm="6" class="myColScan" style>
                <label class="label">行政区划</label>
                <Cascader
                  v-model="currentSelectRegionCode"
                  :data="regionCascader"
                  change-on-select
                  filterable
                  transfer
                  class="input"
                  :load-data="loadRegionData"
                  @on-change="regionChangeEvent"
                ></Cascader>
              </CCol>
            </CRow>
            <!-- 第三行 -->
            <CRow class="rowstyle">
              <CCol sm="6" class="myColtemp" style>
                <label class="label">重点区域</label>
                <Cascader
                  :data="importantRegionCascader"
                  v-model="importantRegionCode"
                  change-on-select
                  filterable
                  class="input"
                  @on-change="importRegionChangeEvent"
                ></Cascader>
              </CCol>
              <CCol sm="6" class="myColtemp">
                <label class="label">时间类型</label>
                <Select
                  v-model="addDataTaskParam.loopTime"
                  filterable
                  class="input"
                  @on-change="loopTimeType"
                >
                  <Option
                    v-for="item in timeTypeList"
                    :value="item.value"
                    :key="item.value"
                    >{{ item.label }}</Option
                  >
                </Select>
              </CCol>
            </CRow>
            <!-- 第四行 -->
            <CRow class="rowstyle">
              <CCol sm="6" class="myColtemp" style>
                <label class="label">灾种</label>
                <Select 
                  v-model="addData.taskDetail" 
                  @on-change="disasterType" 
                  placeholder="请选择灾种类型..." 
                  class="input">
                  <Option 
                    v-for="item in disasterClassify" 
                    :value="item.name" 
                    :key="item.name">
                    {{ item.name }}
                  </Option>
                </Select>
              </CCol>

              <CCol sm="6" class="myColtemp" style>
                <label class="label">数据类型</label>
                <Select
                  v-if="isShowLevel4()"
                  v-model="addDataTaskParam.productType"
                  filterable
                  class="input"
                  @on-change="productTypeValue"
                >
                  <Option
                    :option="getLevelDataType"
                    v-for="item in getLevelDataType"
                    :value="item.value"
                    :key="item.value"
                    >{{ item.label }}</Option
                  >
                </Select>
                <Cascader
                v-else 
                :data="dataTypeList_Level4" 
                v-model="addDataTaskParam.satelliteSensor" 
                @on-change="satelliteSensorType"
                class="input"></Cascader>
              </CCol>
            </CRow>
            <!-- 第五行 -->
            <CRow class="rowstyle">
              <!-- <CCol sm="6" class="myColtemp" style>
                <label class="label">数据类型</label>
                <Select
                  v-model="selectDataType"
                  filterable
                  class="input"
                >
                  <Option
                    v-for="item in dataTypeList"
                    :value="item.value"
                    :key="item.value"
                    >{{ item.label }}</Option
                  >
                </Select>
              </CCol> -->
              <CCol sm="6" class="myColtemp" style>
                <label class="label">产品级别</label>
                <Select
                  v-model="addDataTaskParam.level"
                  filterable
                  @on-change="levelType"
                  class="input"
                >
                  <Option
                    v-for="item in productLevelList"
                    :value="item.value"
                    :key="item.value"
                    >{{ item.label }}</Option
                  >
                </Select>
              </CCol>
              <CCol sm="6" class="myColtemp" style>
                <label class="label">流程选择</label>
                <Select
                  v-model="addData.selectFlowID"
                  filterable
                  transfer
                  @on-select="processingOnChange"
                  class="input"
                >
                  <Option
                    v-for="item in processingList"
                    :value="item.id"
                    :key="item.id"
                    >{{
                      item.workflowName + "-" + item.workflowVersion + ".0"
                    }}</Option
                  >
                </Select>
              </CCol>
            </CRow>
          </div>
          <table class="table0" v-show="isShow">
            <tbody>
              <tr>
                <td>
                  <div class="position-relative table-responsive1">
                    <table class="table table-hover">
                      <tbody>
                        <tr v-show="showGlobalParameter">
                          <td>
                            <div class="tbHeader">
                              <span style="float: left">基本参数：</span>
                              <CButton
                                class="hoverstyle imgBtn"
                                id="globalParamId"
                                :title="'显示更多参数'"
                                variant="outline"
                                color="info"
                                :flag="'display'"
                                @click="displayDtParamBtn('globalBtn')"
                              >
                                <img
                                  class="jia"
                                  :src="tdRightImg('plus')"
                                  alt
                                />
                              </CButton>
                            </div>
                            <CDataTable
                              :items="globalItems"
                              :fields="fields"
                              class="paramTable globalTag"
                              :header="haveHeader"
                              hover
                            >
                              <template #value="{ item }" style="width: 60%">
                                <td>
                                  <CSelect
                                    v-if="
                                      item.type.name.toLowerCase() === 'select'
                                    "
                                    horizontal
                                    :options="item.constraint"
                                    :value.sync="item.default"
                                    class="inputSelectTd"
                                    placeholder="请选择"
                                  ></CSelect>
                                  <CSelect
                                    v-else-if="
                                      item.type.name.toLowerCase() === 'boolean'
                                    "
                                    horizontal
                                    :options="[
                                      { label: '请选择', value: '' },
                                      { label: '是', value: true },
                                      { label: '否', value: false },
                                    ]"
                                    :value.sync="item.default"
                                    class="inputSelectTd"
                                  ></CSelect>
                                  <div
                                    v-else-if="
                                      item.type.name.toLowerCase() === 'dir'
                                    "
                                  >
                                    <template>
                                      <CInput
                                        v-model="item.default"
                                        clearable
                                        autocomplete="off"
                                        class="inputTd"
                                      />
                                      <CButton
                                        color="info"
                                        size="sm"
                                        @click="browserFile(item)"
                                        class="btnBrowser"
                                        >...</CButton
                                      >
                                    </template>
                                  </div>
                                  <div
                                    v-else-if="
                                      item.type.name.toLowerCase() === 'file'
                                    "
                                  >
                                    <template horizontal>
                                      <CInput
                                        v-model="item.default"
                                        clearable
                                        autocomplete="off"
                                        class="inputTd"
                                      />
                                      <CButton
                                        color="info"
                                        size="sm"
                                        @click="browserFile(item)"
                                        class="btnBrowser"
                                        >...</CButton
                                      >
                                    </template>
                                  </div>
                                  <div
                                    v-else-if="
                                      item.type.name.toLowerCase() ===
                                      'spatialref'
                                    "
                                  >
                                    <template>
                                      <CInput
                                        v-model="item.default"
                                        clearable
                                        autocomplete="off"
                                        class="inputTd"
                                      />
                                      <CButton
                                        color="info"
                                        size="sm"
                                        @click="browserRef(item)"
                                        class="btnBrowser"
                                        >...</CButton
                                      >
                                    </template>
                                  </div>

                                  <div
                                    v-else-if="
                                      item.type.name.toLowerCase() === 'float'
                                    "
                                    class="inputTd"
                                  >
                                    <Form
                                      :model="item"
                                      :rules="ruleCustom"
                                      ref="item"
                                    >
                                      <FormItem
                                        prop="default"
                                        :rules="[
                                          {
                                            validator: (
                                              rule,
                                              value,
                                              callback
                                            ) => {
                                              let data = item;
                                              if (
                                                !data.hasOwnProperty(
                                                  'constraint'
                                                )
                                              )
                                                callback();
                                              let min = data.constraint.min;
                                              let max = data.constraint.max;
                                              let num = parseFloat(value);
                                              var reg = /-?[0-9]*\.?[0-9]+/;
                                              if (
                                                new RegExp(reg).test(value) ==
                                                false
                                              ) {
                                                if (max == undefined) {
                                                  callback(
                                                    '请输入' + min + '以上的值'
                                                  );
                                                } else
                                                  callback(
                                                    '请输入' +
                                                      min +
                                                      '-' +
                                                      max +
                                                      '之间的值'
                                                  );
                                              } else {
                                                if (max == undefined) {
                                                  if (num >= min) callback();
                                                  else
                                                    callback(
                                                      '请输入' +
                                                        min +
                                                        '以上的值'
                                                    );
                                                } else {
                                                  if (num >= min && num <= max)
                                                    callback();
                                                  else {
                                                    if (max == undefined)
                                                      callback(
                                                        '请输入' +
                                                          min +
                                                          '以上的值'
                                                      );
                                                    else
                                                      callback(
                                                        '请输入' +
                                                          min +
                                                          '-' +
                                                          max +
                                                          '之间的值'
                                                      );
                                                  }
                                                }
                                              }
                                            },
                                          },
                                        ]"
                                      >
                                        <Input
                                          v-model="item.default"
                                          clearable
                                          autocomplete="off"
                                          placeholder="请输入浮点数"
                                        />
                                      </FormItem>
                                    </Form>
                                  </div>
                                  <CInput
                                    v-else
                                    v-model="item.default"
                                    clearable
                                    class="inputTd"
                                  />
                                </td>
                              </template>
                            </CDataTable>
                          </td>
                        </tr>
                        <tr
                          v-for="(item2, index) in inputDisplayParamItems"
                          :key="index"
                          v-show="showInputParameter"
                        >
                          <td>
                            <div class="tbHeader">
                              <span style="float: left"
                                >{{ item2.groupName }}算法：</span
                              >
                              <CButton
                                :id="`${item2.groupName}_${index}`"
                                class="hoverstyle imgBtn"
                                :title="'显示更多参数'"
                                variant="outline"
                                color="info"
                                :flag="'display'"
                                @click="displayDtParamBtn(item2, index)"
                              >
                                <img
                                  class="jia"
                                  :src="tdRightImg('plus')"
                                  alt
                                />
                              </CButton>
                            </div>
                            <CDataTable
                              :items="item2"
                              :fields="fields"
                              :class="
                                `${item2.length}` < 1
                                  ? 'paramTable paramTable1 '
                                  : 'paramTable'
                              "
                              :header="haveHeader"
                              hover
                              ref="multipleTable"
                              :title="`${item2.groupName}算法`"
                              :columnFilterValue.sync="ceshi"
                            >
                              <template #value="{ item }" style="width: 60%">
                                <td>
                                  <CSelect
                                    v-if="
                                      item.type.name.toLowerCase() === 'select'
                                    "
                                    horizontal
                                    :options="item.constraint"
                                    :value.sync="item.default"
                                    class="inputSelectTd"
                                    placeholder="请选择"
                                  ></CSelect>
                                  <CSelect
                                    v-else-if="
                                      item.type.name.toLowerCase() === 'boolean'
                                    "
                                    horizontal
                                    :options="[
                                      { label: '请选择', value: '' },
                                      { label: '是', value: true },
                                      { label: '否', value: false },
                                    ]"
                                    :value.sync="item.default"
                                    class="inputSelectTd"
                                  ></CSelect>
                                  <div
                                    v-else-if="
                                      item.type.name.toLowerCase() === 'dir'
                                    "
                                  >
                                    <template>
                                      <CInput
                                        v-model="item.default"
                                        clearable
                                        autocomplete="off"
                                        class="inputTd"
                                      />
                                      <CButton
                                        color="info"
                                        size="sm"
                                        @click="browserFile(item)"
                                        class="btnBrowser"
                                        >...</CButton
                                      >
                                    </template>
                                  </div>
                                  <div
                                    v-else-if="
                                      item.type.name.toLowerCase() === 'file'
                                    "
                                  >
                                    <template horizontal>
                                      <CInput
                                        v-model="item.default"
                                        clearable
                                        autocomplete="off"
                                        class="inputTd"
                                      />
                                      <CButton
                                        color="info"
                                        size="sm"
                                        @click="browserFile(item)"
                                        class="btnBrowser"
                                        >...</CButton
                                      >
                                    </template>
                                  </div>
                                  <div
                                    v-else-if="
                                      item.type.name.toLowerCase() ===
                                      'spatialref'
                                    "
                                  >
                                    <template>
                                      <CInput
                                        v-model="item.default"
                                        clearable
                                        autocomplete="off"
                                        class="inputTd"
                                      />
                                      <CButton
                                        color="info"
                                        size="sm"
                                        @click="browserRef(item)"
                                        class="btnBrowser"
                                        >...</CButton
                                      >
                                    </template>
                                  </div>
                                  <div
                                    v-else-if="
                                      item.type.name.toLowerCase() === 'float'
                                    "
                                    class="inputTd"
                                  >
                                    <Form
                                      :model="item"
                                      :rules="ruleCustom"
                                      ref="item"
                                    >
                                      <FormItem
                                        prop="default"
                                        :rules="[
                                          {
                                            validator: (
                                              rule,
                                              value,
                                              callback
                                            ) => {
                                              let data = item;
                                              if (
                                                !data.hasOwnProperty(
                                                  'constraint'
                                                )
                                              )
                                                callback();
                                              let min = data.constraint.min;
                                              let max = data.constraint.max;
                                              let num = parseFloat(value);
                                              var reg = /-?[0-9]*\.?[0-9]+/;
                                              if (
                                                new RegExp(reg).test(value) ==
                                                false
                                              ) {
                                                if (max == undefined) {
                                                  callback(
                                                    '请输入' + min + '以上的值'
                                                  );
                                                } else
                                                  callback(
                                                    '请输入' +
                                                      min +
                                                      '-' +
                                                      max +
                                                      '之间的值'
                                                  );
                                              } else {
                                                if (max == undefined) {
                                                  if (num >= min) callback();
                                                  else
                                                    callback(
                                                      '请输入' +
                                                        min +
                                                        '以上的值'
                                                    );
                                                } else {
                                                  if (num >= min && num <= max)
                                                    callback();
                                                  else {
                                                    if (max == undefined)
                                                      callback(
                                                        '请输入' +
                                                          min +
                                                          '以上的值'
                                                      );
                                                    else
                                                      callback(
                                                        '请输入' +
                                                          min +
                                                          '-' +
                                                          max +
                                                          '之间的值'
                                                      );
                                                  }
                                                }
                                              }
                                            },
                                          },
                                        ]"
                                      >
                                        <Input
                                          v-model="item.default"
                                          clearable
                                          autocomplete="off"
                                          placeholder="请输入浮点数"
                                        />
                                      </FormItem>
                                    </Form>
                                  </div>
                                  <CInput
                                    v-else
                                    v-model="item.default"
                                    clearable
                                    class="inputTd"
                                  />
                                </td>
                              </template>
                            </CDataTable>
                          </td>
                        </tr>
                      </tbody>
                    </table>
                  </div>
                </td>
              </tr>
            </tbody>
          </table>
          <div class="productDiv" v-show="productLine">
            <Tree
              @on-select-change="selectTree"
              :data="productionLineTree"
              ref="resTree"
              class="proTree"
            ></Tree>
            <Table
              style="width: 50%"
              border
              stripe
              :columns="getColumn2"
              :data="data2"
              max-height="480"
              @on-row-click="getTableData"
            ></Table>
          </div>
        </CCardBody>
      </CCard>
    </div>
    <CModal
      title="选择目录"
      color="info"
      :show.sync="showZtreeModal"
      :closeOnBackdrop="false"
      size="lg"
      centered
    >
      <div style="height: 60px">
        <div>
          <CLink class="px-2" @click="shareMenu(currenItem)">共享文件夹</CLink>
          <br />
          <CLink class="px-2" @click="userMenu(currenItem)">用户文件夹</CLink>
          <!-- <br>
          <CLink class="px-2" >数据订单</CLink>-->
        </div>
        <div class="optiostyle displaySuffix" style="display: none">
          <CInputCheckbox
            label="是否批量"
            type="radio"
            :checked.sync="isBatch"
            value="是否批量"
          />
          <CSelect
            label="过滤条件"
            horizontal
            :options="suffix"
            :value.sync="currenSelectSuffix"
            class="selectSuffix"
          ></CSelect>
          <CButton color="info" @click="suffixSearch" class="suffixBtn"
            >过滤</CButton
          >
        </div>
      </div>
      <div class="treeDiv">
        <ul id="treeDemo" class="ztree"></ul>
      </div>

      <template #header>
        <h5>选择目录</h5>
        <CButtonClose @click="menuCancel" />
      </template>
      <template #footer>
        <CButton @click="menuSaveAs" color="info">另存为</CButton>
        <CButton @click="menuOk" color="info">确定</CButton>
        <CButton @click="menuCancel" color="light ">取消</CButton>
      </template>
    </CModal>
    <CModal
      title="推送任务选择目录"
      color="info"
      :show.sync="showPushTaskZtreeModal"
      :closeOnBackdrop="false"
      size="lg"
      centered
    >
      <div class="treeDiv">
        <ul id="updatePushTaskTree" class="ztree"></ul>
      </div>

      <template #header>
        <h5>选择目录</h5>
        <CButtonClose @click="pushTaskMenuCancel" />
      </template>
      <template #footer>
        <CButton @click="pushTaskMenuOk" color="info">确定</CButton>
        <CButton @click="pushTaskMenuCancel" color="light">取消</CButton>
      </template>
    </CModal>
    <CModal
      title="表单验证测试"
      color="info"
      :show.sync="testModal"
      :closeOnBackdrop="false"
      size="sm"
      centered
    >
      <Form
        ref="formCustom"
        :model="formCustom"
        :rules="ruleCustom"
        :label-width="80"
      >
        <FormItem label="Age" prop="age">
          <Input type="text" v-model="formCustom.age" />
        </FormItem>
        <FormItem label="count" prop="count">
          <Input type="text" v-model="formCustom.count" />
        </FormItem>
      </Form>
    </CModal>
  </div>
</template>
<script>
const fields = [
  { key: "label", label: "参数名称", _style: "width:20%;text-align:right" },
  { key: "value", label: "参数值", _style: "width:80%;" },
];
export default {
  name: "addDataUploadTask",
  computed: {
    getColumn2() {
      return [{ key: "workflowName", title: "流程名称", align: "center" }];
    },
    getLevelDataType(){
      if (this.addDataTaskParam.level=="LEVEL5") {
        this.dataTypeList = this.dataTypeList_Level5;
      } else if(this.addDataTaskParam.level=="LEVEL6"){
        this.dataTypeList = this.dataTypeList_Level6;
      }
      return this.dataTypeList;
    },
  },
  data() {
    var validateuser = function (rule, value, callback) {
      if (!value) {
        return callback(new Error("请输入用户名"));
      } else if (!/^[a-zA-Z\d]+$/.test(value)) {
        return callback(new Error("请正确输入用户名"));
      } else {
        callback();
      }
    };
    var validateAge = (rule, value, callback) => {
      if (!Number.isInteger(+value)) {
        callback(new Error("请输入数字"));
      } else {
        callback();
      }
    };
    var validateCount = (rule, value, callback) => {
      if (!Number.isInteger(+value)) {
        callback(new Error("请输入数字"));
      } else if (Number.isInteger(+value)) {
        let num = Number(value);
        let length = value.length;
        if (length < 3) {
          callback(new Error("请输入长度为3的数字"));
        } else {
          callback();
        }
      } else {
        callback();
      }
    };

    return {
      disasterClassify:[],
      currentSelectRegionCode: [],
      importantRegionCode: [], //重点区域
      taskId: 0,

      isShow: false,
      testModal: false,
      ceshi: null,
      inputDisplayParamItems: [], //表格默认显示
      inputParamItems: [], //表格显示和隐藏全部参数
      hiddenDtParam: [], //表格隐藏参数
      displayDtParam: [], //表格显示参数
      productName: "",
      productLine: false,
      productionLineTree: [],
      fields,
      showInputParameter: false,
      showGlobalParameter: false,
      // showMoreTr: false,
      // showBtn: true,
      // hideBtn: false,
      // hideTr: false,
      data: [],
      data2: [],
      sate: "",
      sensor: "",
      flowId: "",
      sourceId: 6,
      formCustom: {
        age: 10,
        count: 1,
      },
      ruleCustom: {
        age: [
          { required: true, message: "年龄不能为空", trigger: "blur" },
          { validator: validateAge, trigger: "blur" },
        ],
        count: [
          { required: true, message: "数量不能为空", trigger: "blur" },
          { validator: validateCount, trigger: "blur" },
        ],
        default: [
          { required: true, message: "请输入数字", trigger: "blur" },
          { validator: validateCount, trigger: "blur" },
        ],
      },
      autoTask: [],
      cronList: [],
      // pushTaskType: "EmergencyTask",
      bIsRoutineTask: false,
      bIsScanDir: true,
      // taskTypeList: [
      //   {
      //     value: "",
      //     label: "请选择",
      //   },
      //   {
      //     value: "RoutineTask",
      //     label: "常规任务",
      //   },
      //   // {
      //   //   value: "EmergencyTask",
      //   //   label: "应急任务"
      //   // }
      // ],
      typeList: [],
      items: [],
      globalItems: [],
      crontabExpressTypeList: [
        {
          value:'0 59 23 ? * *',
          label: "每天",
        },
        {
          value:'0 59 23 ? * SUN',
          label: "每周",
        },
        {
          value:'0 59 23 ? * *',
          label: "每旬",
        },
        {
          value:'0 59 23 L * ?',
          label: "每月",
        },
        {
          value:'0 59 23 L * ?',
          label: "每季度",
        },
      ],
      addData: {
        taskName: "",
        crontabExpress: "",
        crontabDescribe: "",
        taskDetail: "",// 灾种
        selectFlowID: "",
        taskParameter: "",
        // flowName: "",
        // flowId: "",
      },
      addDataTaskParam: {
        level: "",
        loopTime: "",
        processPath: "",
        productType: "",
        satelliteSensor: {},
        regionCode:"",
        keyAreaId:""
        // selectTimeType: "",
        // selectDataType: "",
        // disasterType: "",
        // processDir: "",
        // pendingSuffix: "",
        // finishFlag: ".fin",
        // interval: "",
        // queryParam: {},
        // regionCode: "",
      },
      // fileTypeList: [".gz", ".zip"],
      // curFileType: ".gz",
      showPushTaskZtreeModal: false,
      showZtreeModal: false,
      isBatch: false,
      suffix: [],
      currenSelectSuffix: "",
      haveHeader: false,

      queryTime: [],

      /** 新加参数 */
      selectFlowID: 0,
      selectTimeType: "",
      selectDataType: "",
      selectProductLevel: "",
      area: [],

      processingList: [],
      regionCascader: [
        {
          label: "全国",
          value: 0,
          loading: false,
          tag: "china",
          code: 0,
          children: [],
        },
      ],
      importantRegionCascader: [],
      regionProviceCode: 22,
      cityNumber: 0,
      currentRegionCode: "",
      currentImportantRegionCode: "",
      timeTypeList: [
        {
          value: "day",
          label: "日",
        },
        {
          value: "week",
          label: "周",
        },
        {
          value: "xun",
          label: "旬",
        },
        {
          value: "month",
          label: "月",
        },
        {
          value: "season",
          label: "季度",
        },
      ],
      productLevelList: [
        {
          value: "LEVEL4",
          label: "LEVEL4",
        },
        {
          value: "LEVEL5",
          label: "LEVEL5",
        },
        {
          value: "LEVEL6",
          label: "LEVEL6",
        },
      ],
      dataTypeList:[],
      dataTypeList_Level4: [
        {
          value:'GF1',
          label: 'GF1',
          children: [
            {
              value:'PMS',
              label: 'PMS',
            },
            {
              value:'WFV',
              label: 'WFV',
            }
          ]
        },
        {
          value: 'GF1B',
          label: 'GF1B',
          children:[
            {
              value:'PMS',
              label:'PMS'
            }
          ]
        },
        {
          value: 'GF1C',
          label: 'GF1C',
          children:[
            {
              value:'PMS',
              label:'PMS'
            }
          ]
        },
        {
          value: 'GF1D',
          label: 'GF1D',
          children:[
            {
              value:'PMS',
              label:'PMS'
            }
          ]
        },
        {
          value: 'GF2',
          label: 'GF2',
          children:[
            {
              value:'PMS',
              label:'PMS'
            }
          ]
        },
        {
          value: 'GF3',
          label: 'GF3',
          children:[
            {
              value:'FSII',
              label:'FSII'
            },
            {
              value:'FSI',
              label:'FSI'
            },
            {
              value:'UFS',
              label:'UFS'
            },
            {
              value:'SS',
              label:'SS'
            },
            {
              value:'SL',
              label:'SL'
            },
            {
              value:'NSC',
              label:'NSC'
            },
            {
              value:'WSC',
              label:'WSC'
            },
            {
              value:'QPSI',
              label:'QPSI'
            }
          ]
        },
        {
          value:'GF3B',
          label:'GF3B',
          children:[
            {
              value:'FSII',
              label:'FSII'
            },
            {
              value:'FSI',
              label:'FSI'
            },
            {
              value:'UFS',
              label:'UFS'
            },
            {
              value:'SS',
              label:'SS'
            },
            {
              value:'SL',
              label:'SL'
            },
            {
              value:'NSC',
              label:'NSC'
            },
            {
              value:'WSC',
              label:'WSC'
            },
            {
              value:'QPSI',
              label:'QPSI'
            }
          ]
        },
        {
          value:'GF3C',
          label:'GF3C',
          children:[
            {
              value:'FSII',
              label:'FSII'
            },
            {
              value:'FSI',
              label:'FSI'
            },
            {
              value:'UFS',
              label:'UFS'
            },
            {
              value:'SS',
              label:'SS'
            },
            {
              value:'SL',
              label:'SL'
            },
            {
              value:'NSC',
              label:'NSC'
            },
            {
              value:'WSC',
              label:'WSC'
            },
            {
              value:'QPSI',
              label:'QPSI'
            }
          ]
        },
        {
          value:'GF4',
          label:'GF4',
          children:[
            {
              value:'PMI',
              label:'PMI',
            },
            {
              value:'IRS',
              label:'IRS',
            },
            {
              value:'PMS',
              label:'PMS',
            }
          ]
        },
        {
          value:'GF5',
          label:'GF5',
          children:[
            {
              value:'VIMS',
              label:'VIMS',
            },
            {
              value:'AHSI',
              label:'AHSI',
            }
          ]
        },
        {
          value:'GF6',
          label:'GF6',
          children:[
            {
              value:'PMS',
              label:'PMS',
            },
            {
              value:'WFV',
              label:'WFV',
            }
          ]
        },
        {
          value:'HJ2A',
          label:'HJ2A',
          children:[
            {
              value:'CCD',
              label:'CCD',
            },
            {
              value:'HIS',
              label:'HIS',
            },{
              value:'IRS',
              label:'IRS',
            },
            {
              value:'PSAC',
              label:'PSAC',
            }
          ]
        },
        {
          value:'HJ2B',
          label:'HJ2B',
          children:[
            {
              value:'CCD',
              label:'CCD',
            },
            {
              value:'HIS',
              label:'HIS',
            },{
              value:'IRS',
              label:'IRS',
            },
            {
              value:'PSAC',
              label:'PSAC',
            }
          ]
        }
      ],
      dataTypeList_Level5: [
        {
          value: "YI01",
          label: "水体指数(YI01)",
        },
        {
          value: "YI02",
          label: "归一化植被指数(YI02)",
        },
        {
          value: "YI03",
          label: "增强型植被指数(YI03)",
        },
        {
          value: "YI04",
          label: "积雪指数(YI04)",
        },
        {
          value: "YI05",
          label: "陆表温度反演(YI05)",
        },
        {
          value: "YI06",
          label: "叶面积指数(YI06)",
        },
        {
          value: "YI07",
          label: "植被覆盖度(YI07)",
        },
        {
          value: "YI08",
          label: "土壤湿度(YI08)",
        },
        {
          value: "YI09",
          label: "云(YI09)",
        },
        {
          value: "YC01",
          label: "居民地(YC01)",
        },
        {
          value: "YC02",
          label: "道路(YC02)",
        },
        {
          value: "YC03",
          label: "机场(YC03)",
        },
        {
          value: "YC04",
          label: "码头(YC04)",
        },
        {
          value: "YC05",
          label: "农作物(YC05)",
        },
        {
          value: "YC06",
          label: "城市建成区(YC06)",
        },
        {
          value: "YC07",
          label: "地表植被(YC07)",
        },
        {
          value: "YH01",
          label: "水体提取(YH01)",
        },
        {
          value: "YH02",
          label: "积雪提取(YH02)",
        },
        {
          value: "YH03",
          label: "冰凌提取(YH03)",
        },
        {
          value: "YH04",
          label: "火点提取(YH04)",
        },
        {
          value: "YH05",
          label: "火烧迹地提取(YH05)",
        },
        {
          value: "YO01",
          label: "大型体育场馆(YO01)",
        },
        {
          value: "YO02",
          label: "大型尾矿库(YO02)",
        },
        {
          value: "YO03",
          label: "大型工厂(YO03)",
        },
        {
          value: "YO04",
          label: "储油罐区(YO04)",
        },
        {
          value: "YO05",
          label: "大型水利设施(YO05)",
        },
        {
          value: "EW01",
          label: "灾害范围监测(EW01)",
        },
        {
          value: "EW02",
          label: "农作物毁损监测(EW02)",
        },
        {
          value: "EW03",
          label: "房屋毁损监测(EW03)",
        },
        {
          value: "EW04",
          label: "道路毁损监测(EW04)",
        },
        {
          value: "EG01",
          label: "灾害范围监测(EG01)",
        },
        {
          value: "EG02",
          label: "农作物毁损监测(EG02)",
        },
        {
          value: "EG03",
          label: "房屋毁损监测(EG03)",
        },
        {
          value: "EG04",
          label: "道路毁损监测(EG04)",
        },
        {
          value: "EF01",
          label: "灾害范围监测(EF01)",
        },
        {
          value: "EF02",
          label: "林草毁损监测(EF02)",
        },
        {
          value: "RD01",
          label: "RD01",
        },
        {
          value: "RD02",
          label: "RD02",
        },
        {
          value: "RD03",
          label: "RD03",
        },
        {
          value: "RD04",
          label: "RD04",
        },
        {
          value: "RD05",
          label: "RD05",
        },
        {
          value: "RD06",
          label: "RD06",
        },
        {
          value: "RD07",
          label: "RD07",
        },
        {
          value: "RD08",
          label: "RD08",
        },
        {
          value: "RD09",
          label: "RD09",
        },
        {
          value: "RD10",
          label: "RD10",
        },
        {
          value: "RD11",
          label: "RD11",
        },
      ],
      dataTypeList_Level6: [
        {
          value: "RD01",
          label: "干旱风险(RD01)",
        },
        {
          value: "RD02",
          label: "干旱风险(RD02)",
        },
        {
          value: "RD03",
          label: "干旱风险(RD03)",
        },
        {
          value: "RD04",
          label: "干旱风险(RD04)",
        },
        {
          value: "RD05",
          label: "干旱风险(RD05)",
        },
        {
          value: "RD07",
          label: "干旱风险(RD07)",
        },
        {
          value: "RD08",
          label: "干旱风险(RD08)",
        },
        {
          value: "RD09",
          label: "干旱风险(RD09)",
        },
        {
          value: "RD10",
          label: "干旱风险(RD10)",
        },
        {
          value: "RD11",
          label: "干旱风险(RD11)",
        },
        {
          value: "RG01",
          label: "地质风险(RG01)",
        },
        {
          value: "RG02",
          label: "地质风险(RG02)",
        },
        {
          value: "RG03",
          label: "地质风险(RG03)",
        },
        {
          value: "RG04",
          label: "地质风险(RG04)",
        },
        {
          value: "RG05",
          label: "地质风险(RG05)",
        },
        {
          value: "RG06",
          label: "地质风险(RG06)",
        },
        {
          value: "RG07",
          label: "地质风险(RG07)",
        },
        {
          value: "RG08",
          label: "地质风险(RG08)",
        },
        {
          value: "RG09",
          label: "地质风险(RG09)",
        },
        {
          value: "RG10",
          label: "地质风险(RG10)",
        },
        {
          value: "RG11",
          label: "地质风险(RG11)",
        },{
          value: "RG01",
          label: "地质风险(RG01)",
        },
        {
          value: "RS01",
          label: "雪灾风险(RS01)",
        },
        {
          value: "RS02",
          label: "雪灾风险(RS02)",
        },

        {
          value: "RS03",
          label: "雪灾风险(RS03)",
        },

        {
          value: "RS04",
          label: "雪灾风险(RS04)",
        },

        {
          value: "RS05",
          label: "雪灾风险(RS05)",
        },

        {
          value: "RS06",
          label: "雪灾风险(RS06)",
        },

        {
          value: "RS01",
          label: "雪灾风险(RS01)",
        },

        {
          value: "RS07",
          label: "雪灾风险(RS07)",
        },

        {
          value: "RS08",
          label: "雪灾风险(RS08)",
        },

        {
          value: "RS09",
          label: "雪灾风险(RS09)",
        },

        {
          value: "RS10",
          label: "雪灾风险(RS10)",
        },

        {
          value: "RS11",
          label: "雪灾风险(RS11)",
        }, 
        {
          value: "RI01",
          label: "海冰冰凌风险(RI01)",
        }, {
          value: "RI02",
          label: "海冰冰凌风险(RI02)",
        },
        {
          value: "RI03",
          label: "海冰冰凌风险(RI03)",
        },
        {
          value: "RI04",
          label: "海冰冰凌风险(RI04)",
        },
        {
          value: "RI01",
          label: "海冰冰凌风险(RI01)",
        },
        {
          value: "RI05",
          label: "海冰冰凌风险(RI05)",
        },
        {
          value: "RI06",
          label: "海冰冰凌风险(RI06)",
        },
        {
          value: "RI07",
          label: "海冰冰凌风险(RI07)",
        },
        {
          value: "RI08",
          label: "海冰冰凌风险(RI08)",
        },
        {
          value: "RI09",
          label: "海冰冰凌风险(RI09)",
        },
        {
          value: "RI10",
          label: "海冰冰凌风险(RI10)",
        },
        {
          value: "RI11",
          label: "海冰冰凌风险(RI11)",
        },
        {
          value: "RR01",
          label: "暴雨洪涝风险(RR01)",
        },
        {
          value: "RR02",
          label: "暴雨洪涝风险(RR02)",
        },
        {
          value: "RR03",
          label: "暴雨洪涝风险(RR03)",
        },
        {
          value: "RR04",
          label: "暴雨洪涝风险(RR04)",
        },
        {
          value: "RR05",
          label: "暴雨洪涝风险(RR05)",
        },
        {
          value: "RR06",
          label: "暴雨洪涝风险(RR06)",
        },
        {
          value: "RR06",
          label: "暴雨洪涝风险(RR06)",
        },
        {
          value: "RR07",
          label: "暴雨洪涝风险(RR07)",
        },
        {
          value: "RR08",
          label: "暴雨洪涝风险(RR08)",
        },
        {
          value: "RR09",
          label: "暴雨洪涝风险(RR09)",
        },
        {
          value: "RR10",
          label: "暴雨洪涝风险(RR10)",
        },
        {
          value: "RR11",
          label: "暴雨洪涝风险(RR11)",
        },
        {
          value: "RF01",
          label: "森林草原风险(RF01)",
        },
        {
          value: "RF02",
          label: "森林草原风险(RF02)",
        },

        {
          value: "RF03",
          label: "森林草原风险(RF03)",
        },

        {
          value: "RF04",
          label: "森林草原风险(RF04)",
        },

        {
          value: "RF05",
          label: "森林草原风险(RF05)",
        },

        {
          value: "RF06",
          label: "森林草原风险(RF06)",
        },

        {
          value: "RF07",
          label: "森林草原风险(RF07)",
        },

        {
          value: "RF08",
          label: "森林草原风险(RF08)",
        },

        {
          value: "RF09",
          label: "森林草原风险(RF09)",
        },
        {
          value: "RF10",
          label: "森林草原风险(RF10)",
        },
        {
          value: "RF11",
          label: "森林草原风险(RF11)",
        },
      ],
      /** 以上为新加参数 */
    };
  },
  watch: {
    groupName(newVal, oldVal) {
      if (newVal.length >= 50) {
        this.$Message.error("任务名称长度不得超过50个字符");
      }
    },
    flowId(newVal, oldVal) {
      this.flowId = newVal;
      this.getParamList(newVal);
    },
    inputDisplayParamItems: {
      handler(newval, oldval) {},
      deep: true,
    },
  },
  mounted() {
    // this.source();
    //this.getModelCategoryTree();
    // this.searchAllProductionLine();
    //this.getDisasterTypeList();
    this.getDisasterClassify();
    this.getCronList();
    this.init();
    
  },
  methods: {
    // 回显表单数据
    getAuto(id) {
      this.taskId = id;
      let self = this;
      debugger;
      let path = this.$api.taskManageApi.queryCopy + "/" + id;
      this.http.get(path).then(async (res) => {
        if (res.data.success) {
          let data = res.data.data;
          self.bIsRoutineTask = true;
          // self.pushTaskType = "RoutineTask";
          self.addData.taskName = data.taskName; //任务名称
          debugger
          self.addData.crontabDescribe = data.crontabDescribe;//扫描间隔
          self.addData.crontabExpress = data.crontabExpress;
          console.log(self.addData.crontabDescribe,self.addData.crontabExpress)
          self.addData.taskDetail = data.taskDetail;//灾种
          self.addData.selectFlowID = Number(data.flowId);//流程选择

          let taskParameter = JSON.parse(data.taskParameter); //JSON转成正常格式

          self.addDataTaskParam.level = taskParameter.level;  //产品级别
          self.addDataTaskParam.loopTime = taskParameter.loopTime;//时间类型
          self.addDataTaskParam.processPath = taskParameter.processPath; //提取目录
          // self.currentSelectRegionCode = taskParameter.regionCode;
          // self.importantRegionCascader = taskParameter.keyAreaId
          // console.log(self.currentSelectRegionCode,self.importantRegionCascader)
          // self.addDataTaskParam.processDir = taskParameter.processDir;
          if(taskParameter.level == "LEVEL4"){
            let satelliteSensorValue = [];
            let satellite = Object.keys(taskParameter.satelliteSensor).toString() 
            let sensor =  Object.values(taskParameter.satelliteSensor)[0].toString();
            satelliteSensorValue = [satellite,sensor];
            self.addDataTaskParam.satelliteSensor = taskParameter.satelliteSensor ? satelliteSensorValue : '';//L4数据类型
          }else{
            self.addDataTaskParam.productType = taskParameter.productType ? taskParameter.productType : '';//L5、L6数据类型
          }
          self.importantRegionCode = []; //组件绑定值
          self.currentSelectRegionCode = [];
          self.currentRegionCode = "";
          console.log(taskParameter.keyAreaId);
          // if (
          //   taskParameter.queryParam.area.length > 0 &&
          //   taskParameter.queryParam.area[0].geoType == "polygon"
          // ) {
            // 重点区域
            // this.area.push(taskParameter.queryParam.area[0]);
            // self.importantRegionCode.push(taskParameter.keyAreaId);
            // self.currentImportantRegionCode = taskParameter.regionCode;
          // } else {
            //行政区划 130102 前2位省  前4位市 6位区县
            let code = taskParameter.regionCode;
            self.currentRegionCode = code;
            let provinceCode = Number(code.substring(0, 2));
            let cityCode = Number(code.substring(0, 4));
            let pIndex = -1;
            let provinceItem = this.regionCascader.filter((ele, index) => {
              if (ele.value === provinceCode) {
                pIndex = index;
                return ele;
              }
            });
            if (code.substring(2, 4) == "00") {//1100  只显示省
              self.currentSelectRegionCode = [provinceCode];
            } else if (code.substring(4, 6) == "00") { //130100 只显示省和市
              self.currentSelectRegionCode = [provinceCode, cityCode];
            } else {
              await this.loadRegionData(provinceItem[0], () => {});
              let cityItem = self.regionCascader[pIndex].children.filter(
                (ele) => {
                  return ele.value === cityCode;
                }
              );
              await this.loadRegionData(cityItem[0], () => {});
              self.currentSelectRegionCode = [
                provinceCode,
                cityCode,
                Number(code),
              ];
              console.log(self.currentSelectRegionCode);
            }
          // }
          // self.selectFlowID = Number(data.flowId); //流程选择
        }
      });
    },
    //灾种分类获取
    getDisasterClassify(){
      let arr = [];
      let path = this.$api.taskManageApi.disasterTypeAll
      this.http.get(path).then((res) => {
        if(res.data.success){
          for(let i = 0; i < res.data.data.length; i++){
            let disasterValue = {
                name:'',
            } 
            disasterValue.name = res.data.data[i].name
            arr.push(disasterValue)
          }
          this.disasterClassify = arr;
        }
      })
    },
    isShowLevel4(){
      if(this.addDataTaskParam.level !== "LEVEL4"){
        return true;
      }else if(this.addDataTaskParam.level !== "LEVEL4"){
        return false;
      }
    },
    selectcronType(val) {
      this.addData.crontabExpress = val.value;
      this.addData.crontabDescribe = val.label;
      // let selectIndex = event.target.options.selectedIndex;
      // this.addData.crontabDescribe = event.target.options[selectIndex].label;
    },
    /** 新加方法 */
    init() {
      this.getProcessingData();
      this.importantRegionOprator();
      this.getProvinceCode();
    },
    processingOnChange(item) {
      this.selectFlowID = item.value;
    },
    getProcessingData() {
      let path = this.$api.queryDealApi.getProduct;
      this.http.get(path).then((res) => {
        if (res.data.code == 0) {
          this.processingList = res.data.data;
        } else {
          this.$Message.error(res.data.message);
        }
      });
    },

    //获取省
    getProvinceCode() {
      let path = this.$api.queryDealApi.regionQueryProvince;
      this.http.get(path).then((res) => {
        if (res.data.code == 200) {
          this.regionCascader = [];
          let province = res.data.data;
          //this.options = [];
          let data1 = [
            // {
            //   code: 1301,
            //   name: "石家庄市",
            //   provinceCode: 13,
            // },
            {
              value: 1301,
              label: "石家庄市",
              provinceCode: 13,
              children: [],
              loading: false,
            },
          ];

          let data2 = [
            // {
            //   code: 130102,
            //   name: "长安区",
            //   provinceCode: 13,
            //   cityCode: 1301,
            // },
            {
              value: 130102,
              label: "长安区",
              provinceCode: 13,
              // loading: false,
            },
          ];
          for (let i = 0; i < province.length; i++) {
            let tempdata = {
              value: province[i].code,
              label: province[i].name,
              loading: false,
              number: i,
              children: [],
              sign: "province",
            };
            // debugger;
            // if (province[i].code == 13) {
            //   tempdata.children = data1;
            //   tempdata.children.forEach((ele) => {
            //     if (ele.value == 1301) ele.children = data2;
            //   });
            // }
            this.regionCascader.push(tempdata);
          }
        }
      });
    },
    // 获取县
    async loadRegionData(item, callback) {
      let _this = this;
      item.loading = true;
      //if(item.loading==false)
      //{
      if (item.sign == "province") {
        this.cityNumber = item.number;
        let path =
          this.$api.queryDealApi.regionQueryCityByProvince + `${item.value}`;
        await this.http.get(path).then((res) => {
          if (res.data.success) {
            let CityData = res.data.data;
            let cityNum = CityData.length;
            for (let i = 0; i < cityNum; i++) {
              let tempdata1 = {
                value: CityData[i].code,
                label: CityData[i].name,
                loading: false,
                number: i,
                children: [],
              };

              this.regionCascader[item.number].children.push(tempdata1);
            }
          }
          item.loading = false;
          callback();
        });
      } else {
        let path =
          this.$api.queryDealApi.regionQueryAreaByCityCode + `${item.value}`;
        await this.http.get(path).then((res) => {
          if (res.data.success) {
            let coutyData = res.data.data;
            let tempData = {};

            for (let j = 0; j < coutyData.length; j++) {
              tempData = {
                value: coutyData[j].code,
                label: coutyData[j].name,
              };
              debugger;
              _this.regionCascader[_this.cityNumber].children[
                item.number
              ].children.push(tempData);
            }
          }
          item.loading = false;
          callback();
        });
      }
    },
    // async getRegion() {
    //   return "sf";
    // },
    //区域值改变
    regionChangeEvent(value, selectedData) {
      if (this.currentImportantRegionCode != "") {
        this.$Message.info("已选择重点区域，此选择会无效");
        return;
      }
      if (value.length == 0) {
        this.currentRegionCode = "";
        this.area = [];
        return;
      }
      this.area = [];
      let valueLen = value.length;
      let code = "0";
      if (valueLen == 1) {
        code = value[0].toString() + "0000";
        this.currentRegionCode = code;
        this.currentImportantRegionCode = "";
        let tempData = {
          geoType: "region",
          geoValue: this.currentRegionCode,
        };
        this.area.push(tempData);
      } else if (valueLen == 2) {
        code = value[1].toString() + "00";
        this.currentRegionCode = code;
        this.currentImportantRegionCode = "";
        let tempData = {
          geoType: "region",
          geoValue: this.currentRegionCode,
        };
        this.area.push(tempData);
      } else if (valueLen == 3) {
        code = value[2].toString();
        this.currentRegionCode = code;
        this.currentImportantRegionCode = "";
        let tempData = {
          geoType: "region",
          geoValue: this.currentRegionCode,
        };
        this.area.push(tempData);
      }
    },

    // 重点区域值改变
    importRegionChangeEvent(value, selectedData) {
      debugger;
      if (this.currentRegionCode != "") {
        this.$Message.info("已选择行政区域，此选择会无效");
        return;
      }
      console.log(value,selectedData);
      if (value.length == 0) {
        this.currentImportantRegionCode = "";
        this.area = [];
        return;
      }
      this.area = [];
      this.currentRegionName = selectedData[0].label;
      //this.currentImportantRegion=selectedData[0].value;

      let b = selectedData[0].value;
      let currentImportantRegions = $.parseJSON(b);
      //this.currentImportantRegion = currentImportantRegions;

      this.currentImportantRegionCode = selectedData[0].code;
      this.currentRegionCode = "";
      let tempData = {
        geoType: "polygon",
        geoValue: currentImportantRegions,
      };
      this.area.push(tempData);
    },
    // 重点区域
    importantRegionOprator() {
      this.importantRegionCascader = [];
      let path = this.$api.queryDealApi.disasterImportRegionQuery;
      this.http.get(path).then((res) => {
        if (res.data.code == 200) {
          let importantRegionLst = res.data.data;
          for (let i = 0; i < importantRegionLst.length; i++) {
            let importantRegion = importantRegionLst[i];
            let tempData2 = {
              code: importantRegion.code, //按照这种格式来，你需要在变化事件里面取范围的时候修改到对应的值
              value: importantRegion.code,
              geoValue: importantRegion.wkt,
              // value: importantRegion.wkt,
              // code: importantRegion.code,
              label: importantRegion.name,

              number: i,
            };
            this.importantRegionCascader.push(tempData2);
          }
        }
      });
    },
    /** 以上为新加方法 */
    disasterType(val){
      this.addData.taskDetail = val;
      console.log(this.addData.taskDetail)
    },
    levelType(val){
      this.addDataTaskParam.level = val;
    },
    loopTimeType(val){
      this.addDataTaskParam.loopTime = val;
    },
    productTypeValue(val){
      this.addDataTaskParam.productType = val;
    },
    satelliteSensorType(val){
      this.addDataTaskParam.satelliteSensor = val;
    },
    // selectFileType(event) {
    //   this.curFileType = event.target.value;
    // },

    tdRightImg(type) {
      let img = {
        plus: require("./../../assets/icons/leftArrow.svg"),
        reduce: require("./../../assets/icons/downArrow.svg"),
      };
      return img[type];
    },
    getTableData(row) {
      this.isShow = true;
      this.productName = row.workflowName;
      this.flowId = row.id;
      this.addData.flowName = row.workflowName;
      this.addData.flowId = `${row.id}`;
      this.productLine = false;
    },
    showProduct() {
      this.productLine = true;
    },
    //查询左侧树
    getModelCategoryTree() {
      let self = this;
      self.productionLineTree = [];
      let path = this.$api.taskManageApi.getTreeCopy;
      this.http.get(path).then((res) => {
        self.loading = false;
        if ((res.status = 200)) {
          if (res.data.data.length > 0) {
            self.productionLineTree = res.data.data;
            self.productionLineTree[0].selected = false;
            self.productId = self.productionLineTree[0].id;
            if (self.productionLineTree[0].children.length > 0) {
              this.children = true;
            } else {
              this.children = false;
            }
          } else {
            self.productId = "0";
            self.pid = "0";
          }
        } else {
          this.$Message.error(res.data.message);
        }
      });
      // this.getProduct(self.productId);
    },
    //查看所有流程
    searchAllProductionLine() {
      let self = this;
      let path = this.$api.taskManageApi.searchCopy;
      this.http.get(path).then((res) => {
        if (res.data.code == 0) {
          let getData = res.data.data;
          let newGetData = [];
          for (var i = 0; i < getData.length; i++) {
            let newTemp = {};
            newTemp.id = getData[i].id;
            newTemp.workflowName = getData[i].workflowName;
            newGetData.push(newTemp);
          }
          console.log(newGetData);
          self.data2 = newGetData;
        } else {
          this.$Message.error(res.data.message);
        }
      });
    },
    getProduct(groupId) {
      let path = this.$api.queryDealApi.search;
      let param = {
        groupId: groupId,
      };
      this.http.get(path, param).then((res) => {
        if (res.data.code == 0) {
          let newData = res.data.data;
          this.data2 = newData;
        } else {
          this.$Message.error(res.data.message);
        }
      });
    },
    selectTree() {
      let self = this;
      self.productId = this.$refs.resTree.getSelectedNodes()[0].id;
      console.log("当前节点信息", this.$refs.resTree.getSelectedNodes());
      self.pid = this.$refs.resTree.getSelectedNodes()[0].parentId;
      if (this.$refs.resTree.getSelectedNodes()[0].children.length > 0) {
        this.children = true;
      } else {
        this.children = false;
      }
      this.getProduct(self.productId);
    },

    getParamList(val) {
      // this.getParamListNew()
      // return
      let workflowId = this.workflowId;
      let defaultPath = this.$api.queryDealApi.searchProcessParameters;
      let param1 = {
        workFlowId: val,
      };
      this.displayDtParam = []; //表格显示数据置空
      this.hiddenDtParam = [];
      this.http.get(defaultPath, param1).then((res) => {
        let data = res.data;

        if (data.success) {
          let inputParam = JSON.parse(data.data.processParameters).inputParam;
          let globalParam = JSON.parse(data.data.processParameters).globalParam;
          let params = JSON.parse(data.data.processParameters);

          //参数显示隐藏
          this.showBtn = true;
          this.showInputParameter = true;
          for (let i = 0; i < inputParam.length; i++) {
            let temp = inputParam[i];
            let display = [];
            let hidden = [];
            for (let j = 0; j < temp.length; j++) {
              let tempValue = temp[j];
              let defaultVal = tempValue.default;
              if (
                tempValue.type.name.toLowerCase() === "select" &&
                typeof defaultVal === "object"
              ) {
                tempValue.default = defaultVal.value;
              }
              // if ((defaultVal != null && defaultVal != "") || defaultVal === 0)
              if (tempValue.hasOwnProperty("display")) {
                if (tempValue.display) display.push(tempValue);
                else hidden.push(tempValue);
              } else {
                display.push(tempValue);
              }
            }
            if (hidden.length < 1) hidden.isDisplay = false;
            display.groupName = temp[0].groupName;
            hidden.groupName = temp[0].groupName;
            this.hiddenDtParam.push(hidden); //显示和隐藏的时候需要更新维护
            this.displayDtParam.push(display); //只在表格初始化的时候用一次
          }
          let dd = this.displayDtParam;

          console.log("520已改为查询全局参数的", params);
          if (
            params.globalParam == undefined ||
            params.globalParam.length < 1
          ) {
            this.showInputParameter = true;
            this.showGlobalParameter = false;

            this.inputDisplayParamItems = this.displayDtParam; //inputParam;
            this.inputParamItems = inputParam; //表格参数全部数据
            this.globalItems = null;
          } else {
            this.showInputParameter = false;
            this.showGlobalParameter = true;
            this.inputDisplayParamItems = this.displayDtParam; // inputParam;
            this.inputParamItems = inputParam;
            this.globalItems = globalParam;
            // console.log("全局参数" + JSON.stringify(globalParam));
          }
        } else {
          this.$Message.error(res.data.message);
        }

        this.$nextTick(() => {
          this.setDisplayHidBtnStyle();
        });
      });
    },
    setDisplayHidBtnStyle() {
      //对显示隐藏按钮样式做判断
      let hiddeItem = this.hiddenDtParam;
      let id = "";
      hiddeItem.forEach((element, index) => {
        id = element.groupName + "_" + index;
        let img = $("#" + id).find("img");
        id = this.getFormatId(id);
        if (element.length < 1) {
          $("#" + id).css("display", "none");
        } else {
          $("#" + id).css("display", "block");
          img.attr("src", this.tdRightImg("plus"));
        }
      });
    },
    //解决Dom元素标签id为特殊字符 根据元素id获取Dom对象失败问题
    getFormatId(srcString) {
      // 转义之后的结果
      var result = srcString;
      // javascript正则表达式中的特殊字符
      var jsSpecialChars = [
        "\\",
        "^",
        "$",
        "*",
        "?",
        ".",
        "+",
        "(",
        ")",
        "[",
        "]",
        "|",
        "{",
        "}",
      ];

      // jquery中的特殊字符,不是正则表达式中的特殊字符
      var jquerySpecialChars = [
        "~",
        "`",
        "@",
        "#",
        "%",
        "&",
        "=",
        "'",
        '"',
        ":",
        ";",
        "<",
        ">",
        ",",
        "/",
      ];

      for (var i = 0; i < jsSpecialChars.length; i++) {
        result = result.replace(
          new RegExp("\\" + jsSpecialChars[i], "g"),
          "\\" + jsSpecialChars[i]
        );
      }

      for (var i = 0; i < jquerySpecialChars.length; i++) {
        result = result.replace(
          new RegExp(jquerySpecialChars[i], "g"),
          "\\" + jquerySpecialChars[i]
        );
      }
      return result;
    },
    displayDtParamBtn(data, index) {
      let id = "";
      let groupName = "";
      let btnName = "";

      if (data === "globalBtn") {
        btnName = "globalBtn";
        //基本参数右侧控制按钮
        id = "globalParamId";
      } else {
        //算法参数右上角显示控制按钮
        groupName = data.groupName; //当前表格算法分组
        id = groupName + "_" + index; //当前td id
      }

      let flag = $("#" + id).attr("flag");
      let img = $("#" + id).find("img");
      if (flag == "display") {
        //显示更多
        $("#" + id).attr("flag", "hidden");
        $("#" + id).attr("title", "隐藏参数");
        img.attr("src", this.tdRightImg("reduce"));

        if (btnName !== "" && data === btnName)
          this.showInputParameter = !this.showInputParameter;
        else this.displayAlgoParam(index);
      } else if (flag == "hidden") {
        //隐藏参数
        $("#" + id).attr("flag", "display");
        $("#" + id).attr("title", "显示更多参数");
        img.attr("src", this.tdRightImg("plus"));

        if (btnName !== "" && data === btnName)
          this.showInputParameter = !this.showInputParameter;
        else this.hiddenAlgoParam(index);
      }
    },
    //显示表格隐藏算法参数
    displayAlgoParam(index) {
      //let groupName = data[0].groupName; //当前表格算法分组
      let currentTableParam = this.inputDisplayParamItems[index];
      let hiddenParam = this.hiddenDtParam[index];

      for (let j = 0; j < hiddenParam.length; j++) {
        let tempHid = hiddenParam[j];
        currentTableParam.push(tempHid);
      }
    },
    // 隐藏表格显示算法参数
    hiddenAlgoParam(index) {
      /**
       * 思路：1、获取当前表格数据源currentTableParam：根据当前点击的表格索引获取当前表格参数
       * 2、移除表格数据源要隐藏的参数：currentTableParam和全局的隐藏参数hiddenParam进行比对 如果hiddenParam的参数和currentTableParam参数相同则移除currentTableParam对应的参数
       * 3、更新隐藏参数列表：在2的基础上判断当前全局的hiddenParam和已经显示到表格中的隐藏参数值是否发生变化 是 用currentTableParam最新的参数替换隐藏参数中对应参数
       */
      let currentTableParam = this.inputDisplayParamItems[index];
      let hiddenParam = this.hiddenDtParam[index];

      for (let i = 0; i < currentTableParam.length; i++) {
        let tempItem = currentTableParam[i];
        hiddenParam.forEach((element, index1) => {
          if (tempItem.name === element.name) {
            currentTableParam.splice(i, 1); //删除索引i的1个元素
            i--; //必须有
          }
        });
      }
    },
    getParamListNew() {
      let workflowId = this.workflowId;
      let path =
        this.$api.queryDealApi.productLineQuery + workflowId + "/findParam";
      this.http.get(path).then((res) => {
        let data = res.data;
        console.log("算法原始参数", data);
        let isDeafault = false;
        if (data.code == 0) {
          let newTempList = [];
          for (var i in data.data) {
            let tempList = [];
            let newDataList = [];
            tempList = data.data[i]["input-parameters"];

            newDataList = this.getData(
              tempList,
              data.data[i].name,
              newDataList,
              isDeafault
            );
            newTempList.push(newDataList);
          }
          this.items = newTempList;
          console.log("表格渲染原始显示参数", newTempList);
        } else {
          this.items = [];
          this.$Message.error(res.data.message);
          this.$Message.error(res.data.message);
        }
      });
    },

    getData(tempList, groupName, newList, isDeafault) {
      let arrData = tempList;
      var tempInfo = [];
      var type = "";
      var enumInfo = "";
      for (var index in arrData) {
        tempInfo = arrData[index];
        type = tempInfo.type.name.toLowerCase();
        enumInfo = tempInfo.constraint;
        let enumObjArr = [];
        if (type === "select") {
          if (isDeafault) {
            enumObjArr = tempInfo.constraint;
          } else {
            enumInfo = tempInfo.constraint.values;
            for (var key in enumInfo) {
              let newObj = new Object();
              newObj.value = key;
              newObj.label = enumInfo[key];
              enumObjArr.push(newObj);
            }
          }
          delete tempInfo.constraint;
          tempInfo.constraint = enumObjArr;
        }
        if (!tempInfo.hasOwnProperty("default")) {
          tempInfo.default = "";
        }
        if (groupName != "") tempInfo.groupName = groupName;
        newList.push(tempInfo);
      }
      return newList;
    },

    changeInput(index) {
      this.listproductLine.map((v, i) => {
        if (i == index) {
          v.isCheck = true;
        } else {
          v.isCheck = false;
        }
      });
      let name = this.listproductLine[index].workflowName;
      let currentTime = this.getTime();
      // this.taskName = name + "_" + this.userName + "_" + currentTime;
    },

    changeInputLevel(index) {
      this.options.map((v, i) => {
        if (i == index) {
          v.isCheck = true;
          this.priorityLevel = v.value;
        } else v.isCheck = false;
      });
    },
    getTime() {
      var date = new Date();
      var year = date.getFullYear();
      var month = date.getMonth() + 1;
      var day = date.getDate();
      var hours = date.getHours();
      var minutes = date.getMinutes();
      var seconds = date.getSeconds();
      if (month < 10) {
        month = "0" + month;
      }
      if (day < 10) {
        day = "0" + day;
      }
      let time = year + month + day + " " + hours + ":" + minutes;
      return time;
    },

    // source() {
    //   let self = this;
    //   let path = this.$api.taskManageApi.sourceCopy;
    //   this.http.get(path).then((res) => {
    //     if (res.data.code == 0) {
    //     } else {
    //       console.log("查询sourceid错误");
    //     }
    //   });
    // },
    menuCancel() {
      this.reset();
    },
    menuOk() {
      let isBatch = this.isBatch;
      var treeObj = $.fn.zTree.getZTreeObj("treeDemo"),
        nodes = treeObj.getCheckedNodes(true);
      let tempNode = "";
      let info = "";
      for (var index in nodes) {
        tempNode = nodes[index];
        if (
          this.currenItem.type.name.toLowerCase() === "file" &&
          tempNode.isParent
        )
          continue;
        if (info == "") info = tempNode.id;
        else if (isBatch) {
          info += "#HT#" + tempNode.id;
        } else {
          info += "#TASK#" + tempNode.id;
        }
      }

      console.log("zuobio之前的参考" + info);
      this.currenItem.default = info;
      this.reset();
    },
    // 过滤条件搜索
    suffixSearch() {
      var treeObj = $.fn.zTree.getZTreeObj("treeDemo"),
        nodes = treeObj.getCheckedNodes(true);
      if (nodes.length < 1) {
        this.$Message.error("没有选中的文件或文件夹");
        return;
      }
      for (var i in nodes) {
        this.getFile(treeObj, nodes[i]);
      }
    },
    // 文件另存为modal界面初始化
    menuSaveAs() {
      let treeObj = $.fn.zTree.getZTreeObj("treeDemo");
      if (treeObj == null) {
        this.$Message.error("请选择文件夹！");
        return;
      }

      let selectNodes = treeObj.getSelectedNodes();
      if (selectNodes.length < 1) {
        this.$Message.error("请选择文件夹节点！");
        return;
      }
      if (!selectNodes[0].isParent) {
        this.$Message.error("请选择文件夹！");
        return;
      }
      this.newFileName = ""; //界面文件名置为空
      this.saveAsModal = true;

      if (this.currenItem.type.name.toLowerCase() === "file") {
        self.isFile = true;
        $(".saveFile").css("display", "block");
        $(".saveFolder").css("display", "none");
      }
      //用于新增文件或文件夹标识
      else {
        $(".saveFile").css("display", "none");
        $(".saveFolder").css("display", "block");
        self.isFile = false;
      }
    },
    saveAsFileOK() {
      let fileName = this.newFileName;
      this.saveAsModal = false;
      let treeObj = $.fn.zTree.getZTreeObj("treeDemo");
      let selectNodes = treeObj.getSelectedNodes();
      let newNode = "";
      if (fileName == null || fileName == "") {
        this.$Message.error("文件名或文件夹名称为空，请重写填写");
      }
      if (isFile) {
        //文件 判断文件名是否符合带后缀
        let a = fileName.split("").reverse().join("");
        let b = a.substring(0, a.search(/\./)).split("").reverse().join("");
        if (b == null || b == "") {
          this.$Message.error("该文件名无效，没有后缀");
          return;
        }
        newNode = {
          name: fileName,
          id: selectNodes[0].id + "/" + fileName,
          isParent: false,
        };
      } else
        newNode = {
          name: fileName,
          id: selectNodes[0].id + "/" + fileName,
          isParent: true,
        };
      if (newNode == null) return;
      treeObj.addNodes(selectNodes[0], 0, newNode, true); //新增节点放在文件夹的顶层并默认选择
      let node = selectNodes[0].children[0];
      node.checked = true;
      treeObj.updateNode(node);
    },

    saveAsFileCancel() {
      this.saveAsModal = false;
    },

    // 任务类型选择变化
    // pushTaskTypeChange(event) {
    //   //debugger;
    //   let self = this;
    //   this.getCronList();
    //   let typeValue = event.target.value;
    //   self.pushTaskType = typeValue;

    //   if (typeValue == "RoutineTask") {
    //     self.bIsRoutineTask = true;
    //   } else {
    //     self.bIsRoutineTask = false;
    //   }
    // },
    // 应急推送任务扫描目录选择
    selectPushTaskScanDir(type) {
      this.bIsScanDir = true;
      this.showPushTaskZtreeModal = true;
      this.pushTaskMenu(type);
    },
    // 应急推送任务生产目录选择
    selectPushTaskProDir(type) {
      this.bIsScanDir = false;
      this.showPushTaskZtreeModal = true;
      this.pushTaskMenu(type);
    },
    // 应急推送任务扫描目录、生产目录Ztree设置
    pushTaskMenuSetting(urlPath) {
      let checkType = { Y: "", N: "" }; //父与子的关联去掉
      let setting = {
        check: {
          enable: true,
          nocheckInherit: false,
          chkboxType: checkType,
        },
        data: {
          simpleData: {
            enable: true,
          },
        },
        callback: {
          beforeClick: this.beforeClick,
          onClick: this.zTreeOnClick,
          onCheck: this.zTreePushTaskOnCheck,
          onExpand: this.zTreeOnClick,
        },
      };

      this.http.get(urlPath).then((res) => {
        let data = res.data;
        if (data.success == true) {
          $.fn.zTree.init($("#updatePushTaskTree"), setting, data.data);
        }
      });
    },
    pushTaskMenu(type) {
      let treeObj = $.fn.zTree.getZTreeObj("updatePushTaskTree");
      if (treeObj != null) {
        var nodes = treeObj.getNodes();
        for (var i = nodes.length - 1; i >= 0; i--) {
          treeObj.removeNode(nodes[i]);
        }
      }

      let path; //1 共享 2 用户 3 推送任务扫描
      if (type == "scanDir" && this.pushTaskType == "EmergencyTask") {
        path = this.$api.taskManageApi.fileRootPath + 1;
      } else {
        path = this.$api.taskManageApi.fileRootPath + 1;
      }
      this.pushTaskMenuSetting(path);
    },
    zTreePushTaskOnCheck(event, treeId, treeNode) {
      var treeObj = $.fn.zTree.getZTreeObj(treeId),
        nodes = treeObj.getCheckedNodes(true);

      if (!treeNode.isParent) {
        this.$Message.error("请选择文件夹！");
        treeNode.checked = false;
        treeObj.updateNode(treeNode);
        return;
      }
      if (!this.bIsScanDir && nodes.length > 1) {
        //限制单个文件夹
        this.$Message.error("生产目录只能选择一个文件夹！");
        treeNode.checked = false;
        treeObj.updateNode(treeNode);
        return;
      }
    },
    pushTaskMenuOk() {
      let treeObj = $.fn.zTree.getZTreeObj("updatePushTaskTree"),
        nodes = treeObj.getCheckedNodes(true);
      let tempNode = "";
      // let info = "";
      let info = this.addDataTaskParam.processPath;
      for (var index in nodes) {
        tempNode = nodes[index];
        if (info == "") {
          info = tempNode.id;
        } else {
          info = tempNode.id;
        }
      }

      if (this.bIsScanDir) {
        //this.addDataTaskParam.scanDir = info;
        this.addDataTaskParam.processPath = info;
      } else {
        this.addDataTaskParam.processPath = info;
      }

      this.pushTaskReset();
    },
    pushTaskMenuCancel() {
      this.pushTaskReset();
    },
    pushTaskReset() {
      var treeObj;
      this.showPushTaskZtreeModal = false;
      treeObj = $.fn.zTree.getZTreeObj("updatePushTaskTree");
      if (treeObj == null) return;

      var nodes = treeObj.getNodes();
      for (var i = nodes.length - 1; i >= 0; i--) {
        treeObj.removeNode(nodes[i]);
      }
    },

    menuSetting(item, urlPath) {
      $(".displaySuffix").css("display", "block");
      let checkType = { Y: "", N: "" }; //父与子的关联去掉
      if (item.type.name.toLowerCase() === "file") {
        checkType = { Y: "s", N: "ps" };
      }
      let setting = {
        check: {
          enable: true,
          nocheckInherit: false,
          chkboxType: checkType,
        },
        data: {
          simpleData: {
            enable: true,
          },
        },
        callback: {
          beforeClick: this.beforeClick,
          onClick: this.zTreeOnClick,
          onCheck: this.zTreeOnCheck,
          onExpand: this.zTreeOnClick,
        },
      };

      this.http.get(urlPath).then((res) => {
        let data = res.data;
        if (data.success == true) {
          $.fn.zTree.init($("#treeDemo"), setting, data.data);
        }
      });
    },
    shareMenu(item) {
      let treeObj = $.fn.zTree.getZTreeObj("treeDemo");
      if (treeObj != null) {
        var nodes = treeObj.getNodes();
        for (var i = nodes.length - 1; i >= 0; i--) {
          treeObj.removeNode(nodes[i]);
        }
      }
      let path = this.$api.taskManageApi.fileRootPath + 1; //1 共享 2 用户
      this.menuSetting(item, path);
    },

    userMenu(item) {
      let treeObj = $.fn.zTree.getZTreeObj("treeDemo");
      if (treeObj != null) {
        var nodes = treeObj.getNodes();
        for (var i = nodes.length - 1; i >= 0; i--) {
          treeObj.removeNode(nodes[i]);
        }
      }
      let path = this.$api.taskManageApi.fileRootPath + 2; //1 共享 2 用户
      this.menuSetting(item, path);
    },

    zTreeOnClick(event, treeId, treeNode) {
      let path = this.$api.taskManageApi.getFileListByPathCopy;
      let param = {
        path: treeNode.id,
      };
      var treeObj = $.fn.zTree.getZTreeObj(treeId);
      var node = treeObj.getNodeByParam("id", treeNode.id);
      treeObj.selectNode(node);
      let sNode = treeObj.getSelectedNodes();
      if (sNode.length > 0) {
        let zAsync = sNode[0].zAsync;
        treeObj.reAsyncChildNodes(treeNode, "refresh");
        if (zAsync) {
        } else {
          this.http.get(path, param).then((res) => {
            let data = res.data;
            if (data.success == true) {
              treeNode.halfCheck = false;
              treeObj.addNodes(treeNode, data.data, false);
              sNode[0].zAsync = true;
            }
          });
        }
      }
    },
    //////////////////////////////////以下为目录浏览功能//////////////////////////////////
    //文件浏览功能
    browserFile(item) {
      let self = this;
      self.currenItem = item;
      this.showZtreeModal = true;
      this.isRefModal = false;

      if (!item.hasOwnProperty("constraint")) {
        self.suffix = [];
        self.currenSelectSuffix = "";
        return;
      }
      let extensions = item.constraint.extensions.split(/[,;]/);
      let tempSuffix = [];
      for (var i in extensions) {
        let newObj = new Object();
        let name = extensions[i];
        newObj.value = name.substring(2, name.length);
        newObj.label = name.substring(2, name.length);
        tempSuffix.push(newObj);
      }
      self.suffix = tempSuffix;
      self.currenSelectSuffix = tempSuffix[0].value;
    },

    browserRef(item) {
      this.isRefModal = true;
      this.showZtreeRefModal = true;
      let self = this;
      self.currenItem = item;
      let path = this.$api.taskManageApi.browserRefPath;
      let setting = {
        check: {
          enable: true,
          nocheckInherit: false,
          chkboxType: { Y: "", N: "" },
        },
        data: {
          simpleData: {
            enable: true,
          },
        },
        callback: {
          // beforeClick: this.beforeClick,
          // onClick: this.zTreeOnClick,
          // onCheck: this.zTreeOnCheck,
          // onExpand: this.zTreeOnClick
        },
      };
      this.http.get(path).then((res) => {
        let data = res.data;
        if (data.success == true) {
          $.fn.zTree.init($("#treeDemo1"), setting, data.data);
          console.log("refTree", data.data);
        }
      });
    },

    menuSetting(item, urlPath) {
      $(".displaySuffix").css("display", "block");
      let checkType = { Y: "", N: "" }; //父与子的关联去掉
      if (item.type.name.toLowerCase() === "file") {
        checkType = { Y: "s", N: "ps" };
      }
      let setting = {
        check: {
          enable: true,
          nocheckInherit: false,
          chkboxType: checkType,
        },
        data: {
          simpleData: {
            enable: true,
          },
        },
        callback: {
          beforeClick: this.beforeClick,
          onClick: this.zTreeOnClick,
          onCheck: this.zTreeOnCheck,
          onExpand: this.zTreeOnClick,
        },
      };

      this.http.get(urlPath).then((res) => {
        let data = res.data;
        if (data.success == true) {
          $.fn.zTree.init($("#treeDemo"), setting, data.data);
        }
      });
    },
    shareMenu(item) {
      let treeObj = $.fn.zTree.getZTreeObj("treeDemo");
      if (treeObj != null) {
        var nodes = treeObj.getNodes();
        for (var i = nodes.length - 1; i >= 0; i--) {
          treeObj.removeNode(nodes[i]);
        }
      }
      let path = this.$api.taskManageApi.fileRootPath + 1; //1 共享 2 用户
      this.menuSetting(item, path);
    },

    userMenu(item) {
      let treeObj = $.fn.zTree.getZTreeObj("treeDemo");
      if (treeObj != null) {
        var nodes = treeObj.getNodes();
        for (var i = nodes.length - 1; i >= 0; i--) {
          treeObj.removeNode(nodes[i]);
        }
      }
      let path = this.$api.taskManageApi.fileRootPath + 2; //1 共享 2 用户
      this.menuSetting(item, path);
    },

    zTreeOnClick(event, treeId, treeNode) {
      let path = this.$api.taskManageApi.getFileListByPathCopy;
      let param = {
        path: treeNode.id,
      };
      var treeObj = $.fn.zTree.getZTreeObj(treeId);
      var node = treeObj.getNodeByParam("id", treeNode.id);
      treeObj.selectNode(node);
      let sNode = treeObj.getSelectedNodes();
      if (sNode.length > 0) {
        let zAsync = sNode[0].zAsync;
        treeObj.reAsyncChildNodes(treeNode, "refresh");
        if (zAsync) {
        } else {
          this.http.get(path, param).then((res) => {
            let data = res.data;
            if (data.success == true) {
              treeNode.halfCheck = false;
              treeObj.addNodes(treeNode, data.data, false);
              sNode[0].zAsync = true;
            }
          });
        }
      }
    },

    zTreeOnCheck(event, treeId, treeNode) {
      var treeObj = $.fn.zTree.getZTreeObj(treeId),
        nodes = treeObj.getCheckedNodes(true);
      let item = this.currenItem;

      if (item.type.name.toLowerCase() === "file") {
        //文件筛选过滤
        // if (!item.type.plural && nodes.length > 1) {
        //   //限制单个文件
        //   this.$Message.error("该文件路径限制只能选一个文件哦！");
        //   treeNode.checked = false;
        //   treeObj.updateNode(treeNode);
        //   return;
        // }
        this.getFile(treeObj, treeNode);
        return;
      }
      if (item.type.name.toLowerCase() === "dir") {
        if (!treeNode.isParent) {
          this.$Message.error("请选择文件夹！");
          treeNode.checked = false;
          treeObj.updateNode(treeNode);
          return;
        }
        if (!item.type.plural && nodes.length > 1) {
          //限制单个文件夹
          this.$Message.error("当前算法限制只能选一个文件夹哦！");
          treeNode.checked = false;
          treeObj.updateNode(treeNode);
          return;
        }
      }
    },

    getFile(treeObj, treeNode) {
      let tempNode;
      let childsArr = [];

      if (treeNode.hasOwnProperty("children") && treeNode.checked) {
        tempNode = treeNode.children;
        this.getChildsByTreeNode(treeNode, childsArr);
        this.getFileBySuffix(treeObj, childsArr);
      } else if (treeNode.checked) {
        let suffix = this.currenSelectSuffix;
        let fileName = treeNode.name.toLowerCase();
        let regValue = fileName.substring(
          fileName.length - suffix.length,
          fileName.length
        );
        if (
          !suffix.hasOwnProperty("value") &&
          regValue !== suffix.toLowerCase()
        ) {
          treeNode.checked = false;
          this.$Message.error("文件格式不符合过滤条件");
        }
        treeObj.updateNode(treeNode);
      }
    },

    getChildsByTreeNode(treeNode, childsArr) {
      if (treeNode.isParent) {
        //是父节点获取所有子节点
        let childs = treeNode.children;
        for (var i in childs) {
          childsArr.push(childs[i]);
          this.getChildsByTreeNode(childs[i], childsArr);
        }
      }
      return childsArr;
    },
    getFileBySuffix(treeObj, childsFiles) {
      let nodes = childsFiles;
      let fileName;
      let regValue;
      let tempNode;
      let suffix = this.currenSelectSuffix;
      if (nodes.length == undefined) {
        if (!nodes.isParent) {
          //文件
          fileName = nodes.name.toLowerCase();
          regValue = fileName.substring(
            fileName.length - suffix.length,
            fileName.length
          );
          if (regValue === suffix) nodes.checked = true;
          else nodes.checked = false;
          treeObj.updateNode(nodes);
        }
      }
      for (var i = 0; i < nodes.length; i++) {
        tempNode = nodes[i];
        this.getFileBySuffix(treeObj, tempNode);
        if (tempNode.isParent) {
          let tempChilds = tempNode.children;
          let num = 0;
          for (var m in tempChilds) {
            if (tempChilds[m].checked) num++;
            if (num > 1) break;
          }
          if (num < 1) {
            tempNode.checked = false;
            treeObj.updateNode(tempNode);
          }
        }
      }
    },

    menuOk() {
      let isBatch = this.isBatch;
      var treeObj = $.fn.zTree.getZTreeObj("treeDemo"),
        nodes = treeObj.getCheckedNodes(true);
      let tempNode = "";
      let info = "";
      for (var index in nodes) {
        tempNode = nodes[index];
        if (
          this.currenItem.type.name.toLowerCase() === "file" &&
          tempNode.isParent
        )
          continue;
        if (info == "") info = tempNode.id;
        else if (isBatch) {
          info += "#HT#" + tempNode.id;
        } else {
          info += "#TASK#" + tempNode.id;
        }
      }

      console.log("zuobio之前的参考" + info);
      this.currenItem.default = info;
      this.reset();
    },
    menuRefOk() {
      let isBisRefModalatch = this.isRefModal;
      var treeObj = $.fn.zTree.getZTreeObj("treeDemo1"),
        nodes = treeObj.getCheckedNodes(true);
      let tempNode = "";
      let info = "";
      for (let i in nodes) {
        if (nodes.length > 1) {
          this.$Message.error("请选择一个参考坐标系");
          break;
        }
        info = nodes[0].content;
        console.log("之前的参考" + info);
        info = info.replace(/[\r\n]/g, "");
        console.log("之后的参考" + info);
        this.currenItem.default = info; //nodes[0].name;
        this.reset();
      }
    },
    menuCancel() {
      this.reset();
    },

    //目录选择页面 重置
    reset() {
      let isRefModal = this.isRefModal;
      var treeObj;
      if (isRefModal) {
        this.showZtreeRefModal = false;
        treeObj = $.fn.zTree.getZTreeObj("treeDemo1");
      } else {
        this.showZtreeModal = false;
        $(".displaySuffix").css("display", "none");
        treeObj = $.fn.zTree.getZTreeObj("treeDemo");
      }

      if (treeObj == null) return;
      var nodes = treeObj.getNodes();
      for (var i = nodes.length - 1; i >= 0; i--) {
        treeObj.removeNode(nodes[i]);
      }
    },

    // 过滤条件搜索
    suffixSearch() {
      var treeObj = $.fn.zTree.getZTreeObj("treeDemo"),
        nodes = treeObj.getCheckedNodes(true);
      if (nodes.length < 1) {
        this.$Message.error("没有选中的文件或文件夹");
        return;
      }
      for (var i in nodes) {
        this.getFile(treeObj, nodes[i]);
      }
    },

    // 文件另存为modal界面初始化
    menuSaveAs() {
      let treeObj = $.fn.zTree.getZTreeObj("treeDemo");
      if (treeObj == null) {
        this.$Message.error("请选择文件夹！");
        return;
      }

      let selectNodes = treeObj.getSelectedNodes();
      if (selectNodes.length < 1) {
        this.$Message.error("请选择文件夹节点！");
        return;
      }
      if (!selectNodes[0].isParent) {
        this.$Message.error("请选择文件夹！");
        return;
      }
      this.newFileName = ""; //界面文件名置为空
      this.saveAsModal = true;

      if (this.currenItem.type.name.toLowerCase() === "file") {
        self.isFile = true;
        $(".saveFile").css("display", "block");
        $(".saveFolder").css("display", "none");
      }
      //用于新增文件或文件夹标识
      else {
        $(".saveFile").css("display", "none");
        $(".saveFolder").css("display", "block");
        self.isFile = false;
      }
    },

    saveAsFileOK() {
      let fileName = this.newFileName;
      this.saveAsModal = false;
      let treeObj = $.fn.zTree.getZTreeObj("treeDemo");
      let selectNodes = treeObj.getSelectedNodes();
      let newNode = "";
      if (fileName == null || fileName == "") {
        this.$Message.error("文件名或文件夹名称为空，请重写填写");
      }
      if (isFile) {
        //文件 判断文件名是否符合带后缀
        let a = fileName.split("").reverse().join("");
        let b = a.substring(0, a.search(/\./)).split("").reverse().join("");
        if (b == null || b == "") {
          this.$Message.error("该文件名无效，没有后缀");
          return;
        }
        newNode = {
          name: fileName,
          id: selectNodes[0].id + "/" + fileName,
          isParent: false,
        };
      } else
        newNode = {
          name: fileName,
          id: selectNodes[0].id + "/" + fileName,
          isParent: true,
        };
      if (newNode == null) return;
      treeObj.addNodes(selectNodes[0], 0, newNode, true); //新增节点放在文件夹的顶层并默认选择
      let node = selectNodes[0].children[0];
      node.checked = true;
      treeObj.updateNode(node);
    },

    saveAsFileCancel() {
      this.saveAsModal = false;
    },
    //////////////////////////////////以上文件浏览功能//////////////////////////////////
    goBack() {
      this.$router.go(-1);
    },
    //
    save(sourceId) {
      // if (!this.bIsRoutineTask) {
      //   console.log('----------------------------')
      //   this.$Message.error("请选择任务类型");
      //   return;
      // }
      if (this.addData.taskName == "") {
        this.$Message.error("请输入任务名称");
        return;
      }
      if(this.addData.crontabExpress == ""){
        this.$Message.error("请选择扫描间隔");
        return;
      }
      if(this.addDataTaskParam.processPath == ""){
        this.$Message.error("请选择提取目录");
        return;
      }
      if (this.addDataTaskParam.loopTime == "") {
        this.$Message.error("请选择时间类型");
        return;
      }
      if(this.addData.taskDetail == ""){
        this.$Message.error("请选择灾种类型");
        return;
      }
      if (this.addDataTaskParam.level == "") {
        this.$Message.error("请选择产品级别");
        return;
      }
      if (this.addDataTaskParam.productType == "" && this.addDataTaskParam.satelliteSensor == "{}") {
        this.$Message.error("请选择数据类型");
        return;
      }
      if (this.addData.selectFlowID == "") {
        this.$Message.error("请选择流程");
        return;
      }
      this.sourceId = sourceId;
      let self = this;
      let path = this.$api.taskManageApi.updateTaskRegularRisk + this.taskId;
      // 查询数据的参数
      self.addDataTaskParam.level = this.addDataTaskParam.level;
      self.addDataTaskParam.loopTime = this.addDataTaskParam.loopTime;
      self.addDataTaskParam.processPath = this.addDataTaskParam.processPath;
      self.addDataTaskParam.productType = this.addDataTaskParam.productType ? this.addDataTaskParam.productType : '';
      if(this.currentRegionCode){
        self.addDataTaskParam.regionCode = this.currentRegionCode;
      }else{
        self.addDataTaskParam.keyAreaId = this.currentImportantRegionCode;
      } 
      if(this.addDataTaskParam.level == "LEVEL4"){
        console.log(this.addDataTaskParam.satelliteSensor)
        let temp1 = this.addDataTaskParam.satelliteSensor[0];
        let temp2 = [this.addDataTaskParam.satelliteSensor[1]];
        let temp = {
          [temp1]: temp2,
        }
        self.addDataTaskParam.satelliteSensor = temp;
      }else {
        self.addDataTaskParam.satelliteSensor = {};
      }
      self.addData.taskParameter = JSON.stringify(self.addDataTaskParam);
      let param = {
        taskName: this.addData.taskName,
        crontabExpress: this.addData.crontabExpress,
        crontabDescribe: this.addData.crontabDescribe,
        taskDetail: this.addData.taskDetail,
        flowId: this.addData.selectFlowID,
        sourceId: 12,
        status: 0,
        taskParameter: this.addData.taskParameter,
      };
      console.log(param)

      this.http.put(path, param).then((res) => {
        if (res.data.success) {
          this.$emit("closeUpdateTaskRegularRisk", false);
          this.$Message.success("编辑成功");
          this.resetAddData();
          this.cancle();
          // self.productName = "";
          // self.curFileType = ".gz";
          // this.saveDefault();
        } else {
          this.$Message.error(res.data.message);
        }
      });
    },
    //取消
    cancle() {
      let self = this;
      self.resetAddData();
      this.$emit("closeaddTaskRegularRisk", false);
      self.isShow = false;
    },
    //重置
    resetAddData() {
      let self = this;
      self.addData.taskName = "" ;
      self.addData.crontabExpress = "";
      self.addData.crontabDescribe = "",
      self.addData.taskDetail = "";
      self.addData.selectFlowID = "";
      self.addData.sourceId = 0 ;
      self.addData.taskParameter = "",
      self.addDataTaskParam.level = "";
      self.addDataTaskParam.loopTime = "";
      self.addDataTaskParam.processPath = "";
      self.addDataTaskParam.productType = "";
      self.addDataTaskParam.satelliteSensor = {};
      // self.pushTaskType = "";
      // self.curDisasterType = "";
      // self.addData.taskName = "";
      // self.addData.crontabExpress = "";
      // self.addData.flowId = "";
      // self.addData.flowName = "";
      // self.addData.sourceId = 0;
      // self.addData.taskParameter = "";
      // self.addDataTaskParam.scanDir = "";
      // self.addDataTaskParam.processPath = "";
      //self.selectProductType=[];
      //self.productTypeList=[];
      //self.addDataTaskParam.disasterProduction=[];
    },

    // saveDefault() {
    //   let self = this;
    //   self.data = [];
    //   let path = this.$api.taskManageApi.updateDefalut;
    //   let defaultParam = { inputParam: [] };
    //   defaultParam.globalParam = this.globalItems;
    //   for (var i in inputParamData)
    //     defaultParam.inputParam.push(inputParamData[i]);
    //   let param = {
    //     processParameters: JSON.stringify(defaultParam),
    //     workFlowId: self.flowId,
    //   };

    //   this.http.post(path, param).then((res) => {
    //     if (res.data.success) {
    //     } else {
    //       this.$Message.error(res.data.message);
    //     }
    //   });
    // },

    getCronList() {
      this.cronList = [];
      let path = this.$api.taskManageApi.getAllChildByDictCode;
      let param = {
        // dictCode: "SMJG",
        dictCode: "cron",
      };
      //debugger;
      this.http.get(path, param).then((res) => {
        if (res.data.code == 0) {
          let dictCodeList = res.data.data.dictCodeList;
          this.cronList.push({ label: "请选择", value: "" });
          for (let dictCode of dictCodeList) {
            let cron = {
              label: dictCode.dictName,
              value: dictCode.dictCode,
            };
            this.cronList.push(cron);
          }
        } else {
          this.$Message.error(res.data.message);
        }
      });
    },
  },
};
</script>
<style scoped>
.hello {
  position: relative;
  left: -12px;
}
.regionCas {
  width: 194px;
  float: right;
  margin-left: -7px;
  margin-top: -16px;
}
.importantRegionCas {
  width: 184px;
  margin-left: -12px;
  margin-top: -10px;
}
.myCol {
  margin-left: 10px;
  display: flex;
  align-items: center;
}
.myColPri {
  width: 13%;
  margin-right: 10px;
}
.myCol1 {
  width: 90px;
  margin-left: 0px;
}
.myColtemp {
  display: flex;
  align-items: center;
}
.myColScan {
  display: flex;
  align-items: center;
}
.myColPro {
  display: flex;
  align-items: center;
  margin-left: -100px;
  left: 50px;
}
.search {
  display: flex;
}
.styImg {
  margin-left: 70px;
}
.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.76563rem;
  line-height: 1.5;
  border-radius: 0.2rem;
  width: 50px;
}
.table-responsive {
  height: 50% !important;
}
.label {
  width: 80px;
  height: 30px;
  text-align: left;
  line-height: 30px;
  font-size: 16px;
  margin-bottom: 0;
}
.m_radio_group {
  height: 21px;
  width: 65%;
}
.m_radio_group label {
  margin: 0;
  margin-right: 1%;
}
.btnStyle {
  margin-right: 0px;
}
.strongstyle {
  font-size: 18px;
}
.cardstyle {
  margin-top: -20px;
  margin-left: 10px;
}
.rowstyle {
  margin-bottom: 25px;
}
.pickstyle {
  width: 50%;
}
.btn-info:hover {
  color: #fff;
  background-color: rgb(105, 140, 247);
  border-color: rgb(78, 105, 189);
}
.clean {
  margin-left: 10px;
}
.listbtn {
  margin-left: 0px;
}
.deletestyle {
  width: 15px;
  height: 15px;
}
.goBtn {
  margin-right: 10px;
}
.input {
  box-sizing: border-box;
  width: 190px;
  height: 30px;
  cursor: pointer;
}
</style>
<style lang='scss' scoped>
.table0 {
  width: 97%; // 611px;
  height: 324px;
  table-layout: fixed;
  border-top: 1px solid #dae1ea;
}
.jia {
  margin: -15px 0 1px -8px;
}
.optiostyle {
  height: 40px;
  width: 370px;
  float: right;
  font-size: 1rem;
  font-weight: bold;
  z-index: 99;
  margin-top: -50px;
}
.saveFileStyle {
  width: 280px;
}
.treeDiv {
  height: 500px;
  width: 760px;
  overflow-y: auto;
}
.treeDiv1 {
  height: 300px;
  width: 300px;
  overflow-y: auto;
}
.suffixBtn {
  margin-left: 10px;
}
.selectSuffix {
  float: left;
  width: 80%;
}
.inputTd {
  float: left;
  width: 80%;
  margin-bottom: 0px;
  margin-top: 4px;
}
.btnBrowser {
  float: right;
  margin-top: 4px;
  margin-bottom: 0px;
}
.btnSelectScanDir {
  width: 40px;
  height: 30px;
  margin-left: 5px;
}
.btnSelectProDir {
  width: 35px;
  height: 29px;
  margin-left: -40px;
  margin-top: 3px;
}

.card-body {
  position: absolute;
  top: 62px !important;
  // overflow-y: auto;
}

.batchSelect {
  width: 550px;
  height: 200px;
  // overflow-x: auto;
  overflow-y: auto;
}
.levelDiv {
  width: 42px;
  float: left;
  padding-top: 6px;
  margin-left: 38px;
}
.inputRadio {
  width: 165px;
  margin-left: 10px;
}
.btn1 {
  margin: 0.3rem;
}
.footDiv {
  width: 100%;
  margin-top: -27px;
  z-index: 99;
}
.outLine {
  color: #3c6ef0;
  border-color: #3c6ef0;
  height: 40px;
  background: rgba(255, 255, 255, 1);
  box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
}
.btn-info:hover {
  color: #fff;
  background-color: rgb(105, 140, 247);
  border-color: rgb(78, 105, 189);
}
.position-relative {
  height: 360px;
  overflow: auto;
}
.card-header {
  height: 60px;
  padding: 0px;
  padding-top: 23px;
  padding-left: 23px;
}

.proTree {
  width: 50%;
  max-height: 480px;
  padding-right: 5px;
  overflow-y: scroll;
  margin-right: 15px;
}
::-webkit-scrollbar-thumb {
  background-color: #7eb8ee;
}
.productDiv {
  background-color: #fff;
  display: flex;
  width: 350px;
  position: absolute;
  // top: 68px;
  // right: 362px;
  top: 168px;
  right: 72px;
  border-left: 1px solid #d8d8d8;
  border-top: 1px solid #d8d8d8;
  border-bottom: 1px solid #d8d8d8;
  border-radius: 5px;
  bottom: 0;
}
.imgBtn {
  position: absolute;
  right: 11px;
  width: 16px;
  height: 16px;
  margin-top: 2px;
}
.tbHeader {
  width: 100%;
  display: inline-block;
}
.paramTable1 {
  display: none;
}
.cdHead {
  height: 60vh !important;
  border: none;
}
.addtask {
  .table td {
    border-top: 0px;
    width: 20%;
  }

  .table-responsive {
    display: block;
    width: 100%;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }
}
.tempxyz {
  button {
    outline: none;
  }

  .table tr {
    td:nth-child(2) {
      padding: 0px;
      text-align: left;
      padding-left: 10px;
    }
  }
}
.tempxyz,
.processstyle,
.modelSty {
  .leftCardBady {
    .card-body {
      top: 0px !important;
    }
  }

  .card {
    margin-bottom: 0px;
    height: calc(100vh - 80px);
  }

  .card-header {
    padding-left: 20px;
    margin-bottom: 0;
    border-bottom: 1px solid;
    background-color: #fff;
    border-color: #d8dbe0;
    position: absolute;
    top: 0;
    width: 100%;
  }

  .card-body {
    -webkit-box-flex: 1;
    -ms-flex: 1 1 auto;
    flex: 1 1 auto;
    min-height: 1px;
    padding: 50px 0px 10px 20px;
    position: absolute !important;
    top: 52px !important;
    bottom: 21px;
    width: 100%;
    height: auto !important;
  }

  .card-footer {
    padding: 0px;
    border-top: 1px solid;
    background-color: #fff;
    border-color: #fff;
    position: absolute;

    width: 100%;
    height: 52px;
    text-align: center;
    display: flex;
    justify-content: flex-end;
    bottom: -1px;
    padding-right: 15px;
  }
}
</style>